package com.twu.biblioteca.movies;

import java.util.ArrayList;
import java.util.List;

public class MovieCollection {

    private List<Movie> movies;
    private static MovieCollection movieCollection;

    public static MovieCollection getInstance() {
        if (movieCollection == null)
            movieCollection = new MovieCollection();

        return movieCollection;
    }

    private MovieCollection() {

        movies = new ArrayList<Movie>();

        movies.add(new Movie("Django Unchained", "Mel Gibson", "2013", Movie.RATING.NONE));
        movies.add(new Movie("Get the Gringo", "Mel Gibson", "2009", Movie.RATING.SEVEN));
        movies.add(new Movie("The 3 idiots", "Raj Khan", "2005", Movie.RATING.ONE));
        movies.add(new Movie("Safe", "Jason Starthum", "2013", Movie.RATING.THREE));
        movies.add(new Movie("SkyFall", "Pierce Brosnan", "2012", Movie.RATING.FIVE));
        movies.add(new Movie("My big greek fat wedding", "Jonathan Elzie", "2001", Movie.RATING.TWO));
        movies.add(new Movie("To Rome with Love", "John Doe", "2011", Movie.RATING.ONE));
        movies.add(new Movie("Die Hard 1", "Bruce Willis", "2007", Movie.RATING.FIVE));
        movies.add(new Movie("Die Hard 2", "Bruce Willis", "2008", Movie.RATING.FOUR));
        movies.add(new Movie("Die Hard 3", "Bruce Willis", "2008", Movie.RATING.SIX));
        movies.add(new Movie("Die Hard 4", "Bruce Willis", "2009", Movie.RATING.EIGHT));
        movies.add(new Movie("Law abiding citizen", "Christopher Tomas", "2010", Movie.RATING.EIGHT));
        movies.add(new Movie("Die Another Day 1", "Pierce Brosnan", "2006", Movie.RATING.EIGHT));
        movies.add(new Movie("Die Another Day 2", "Pierce Brosnan", "2008", Movie.RATING.NINE));
        movies.add(new Movie("X-Men 3", "Josan Huth", "2010", Movie.RATING.EIGHT));
    }

    public Movie checkOut(String movieTitle) {
        for (Movie movie : movies) {
            if (movie.is(movieTitle)) {
                return movie;
            }
        }
        return null;
    }

    public List<Movie> getAll() {
        return movies;
    }
}

